package cn.yer.service;

import cn.yer.dao.YhxxDao;
import cn.yer.dao.ZmglDao;
import cn.yer.entity.LayuiTableData;
import cn.yer.entity.Yhxx;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class HwysService {
    @Autowired
    private YhxxDao yhxxDao;

    private ZmglDao zmglDao=new ZmglDao();

    public LayuiTableData queryAllYh(int page, int limit){

        page--;
        Pageable pageable=new PageRequest(page,limit);
        Page<Yhxx> pageList= yhxxDao.findAll(pageable);

        return new LayuiTableData(0,"",pageList.getTotalElements(),pageList.getContent());
    }


    public JSONObject zmtj(String khxm){

        return zmglDao.zmtj(khxm);
    }
    public List<Yhxx> yhxx(){

        return yhxxDao.findAll();
    }
}
